const db = require("../config/config");
module.exports = {
  //根据用户id，，获取该用户购物车信息
  upDateRoleInfo(req, res) {
    console.log(req.body,'req');
    let roleName=req.body.roleName
    let roleDetail=req.body.roleDetail
    let roleEnable=req.body.roleEnable
    let roleId=req.body.roleId
    console.log(roleName,roleDetail,roleEnable,roleId);
    db.dbMysql(`UPDATE roleInfo SET roleName =?,roleDetail =? ,roleEnable =? WHERE roleId = ?`, [roleName,roleDetail,roleEnable,roleId], function (err, data) {
     for(let i=0;i<data.length;i++){
      if(data[i].roleEnable==0){
           data[i].roleEnable=true
      }
      else{
        data[i].roleEnable=false
      }
     }

      if (data) {
        res.send({
          code: 200,
          data: data,
          msg: "角色管理查询成功",
        });
      } else {
        res.send({
          code: 500,
          msg: "服务器错误",
        });
      }
    });
  },
};
